<?php
/**
 * Dependency console exporter
 *
 * PHP version 5
 *
 * @category  W
 * @package   Services
 * @author    Olivier Hoareau <olivier@phppro.fr>
 * @copyright 2009 PHPPRO http://www.phppro.fr
 * @license   http://dev.phppro.fr/license PHPPRO
 * @version   SVN: $Id:$
 * @link      http://dev.phppro.fr/projects/wdependency
 */
require_once 'W/W.php';
require_once 'W/Dependency/Exporter/Abstract.php';
/**
 * Dependency console exporter
 *
 * @category  W
 * @package   Services
 * @author    Olivier Hoareau <olivier@phppro.fr>
 * @copyright 2009 PHPPRO http://www.phppro.fr
 * @license   http://dev.phppro.fr/license PHPPRO
 * @version   SVN: $Id$
 * @link      http://dev.phppro.fr/projects/wdependency
 */
class W_Dependency_Exporter_Console extends W_Dependency_Exporter_Abstract
{
    private $key;
    public function export($data)
    {
        $root = $data['root'];
        $data = $data['data'];
        echo "\n";
        $key = $this->getKey();
        foreach($data as $type=>$subData) {
            if (null !== $key && $key !== $type) {
                continue;
            }
            echo " [$type]\n";
            foreach($subData as $node=>$items) {
                echo "\n \t$node (".count($items)." link".((1 < count($items)) ? 's' : '').') :'."\n\n";
                arsort($items);
                foreach($items as $subNode=>$weight) {
                    echo " \t\t".$subNode.' => '.$weight."\n";
                }
            }
        }
    }
}